package com.st.buy.manager.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 张双虎
 */
@Configuration
public class RabbitConfig {

    // 配置扇形交换机
    @Bean
    public FanoutExchange fanoutExchange(){
        return  new FanoutExchange("item-add-exchange",true,false);
    }
    //配置两个队列
    @Bean
    public Queue queueItemDetail(){
        return new Queue("item-add-detail",true);
    }
    @Bean
    public Queue queueItemSearch(){
        return new Queue("item-add-search",true);
    }
    //绑定队列到交换机
    @Bean
    public Binding bindingDetail(){
        return BindingBuilder.bind(queueItemDetail()).to(fanoutExchange());
    }
    @Bean
    public Binding bindingSearch(){
        return BindingBuilder.bind(queueItemSearch()).to(fanoutExchange());
    }
}
